package com.aspose.cells;

class zawq extends zawp {
   private int j;
   private int k;
   private int l;
   private int m;
   private boolean n;
   private int o;
   private int p;
   private int q;
   private int r;
   private int s;
   private int t;

   public zawq(zahn[] var1, zagj var2, zaay var3, int var4, int var5, int var6, int var7) {
      super(var1, var2, var3);
      this.j = var4;
      this.k = var5;
      this.l = var6;
      this.m = var7;
      this.n = false;
   }

   private zawq(zawq var1, zaay var2) {
      super(var1.e(var2), (zagj)var1.c.a(var2), var2);
      this.d = var1.d;
      this.j = var1.j;
      this.k = var1.k;
      this.m = var1.m;
      this.l = var1.l;
      this.n = var1.n;
      this.o = var1.o;
      this.q = var1.q;
      this.p = var1.p;
      this.r = var1.r;
   }

   public zahn b(zaay var1) {
      return new zawq(this, var1);
   }

   public boolean b(int var1, int var2) {
      if (this.s == var1 && this.t == var2) {
         return true;
      } else {
         this.h = null;
         this.s = this.j;
         this.t = this.k;
         this.g = 0;

         zahn var3;
         int var4;
         for(var4 = 0; var4 < this.l; ++var4) {
            var3 = this.b[var4];
            if (var3.b(var1, var2)) {
               this.f[var4] = true;
               this.a(var3, var4);
            } else {
               this.f[var4] = false;
               this.e[var4] = false;
               if (this.g == var4) {
                  ++this.g;
               }
            }
         }

         if (this.m > this.l) {
            for(var4 = this.l; var4 < this.m; ++var4) {
               var3 = this.b[var4];
               if (var3.a(var2)) {
                  this.f[var4] = true;
                  this.a(var1, var3.j(), var4);
               } else {
                  this.f[var4] = false;
                  this.e[var4] = false;
                  if (this.g == var4) {
                     ++this.g;
                  }
               }
            }
         }

         if (this.m < this.b.length) {
            for(var4 = this.m; var4 < this.b.length; ++var4) {
               var3 = this.b[var4];
               if (var3.a(var1)) {
                  this.f[var4] = true;
                  this.b(var3.i(), var2, var4);
               } else {
                  this.f[var4] = false;
                  this.e[var4] = false;
                  if (this.g == var4) {
                     ++this.g;
                  }
               }
            }
         }

         if (this.s > var1 && this.m > this.l) {
            if (this.s > var1 + 1) {
               this.s = var1 + 1;
               if (this.g < this.b.length) {
                  com.aspose.cells.a.c.zc.a(this.e, this.g, this.b.length, false);
               }

               this.t = this.k;
            }

            this.C();
            return true;
         } else {
            return this.g < this.b.length;
         }
      }
   }

   private void a(zahn var1, int var2) {
      int var3 = var1.i();
      if (var3 == this.s) {
         var3 = var1.j();
         if (var3 == this.t) {
            this.e[var2] = true;
            return;
         }

         if (var3 > this.t) {
            this.e[var2] = false;
            return;
         }

         this.t = var3;
      } else {
         if (var3 >= this.s) {
            this.e[var2] = false;
            return;
         }

         this.s = var3;
         this.t = var1.j();
      }

      this.e[var2] = true;
      if (this.g < var2) {
         com.aspose.cells.a.c.zc.a(this.e, this.g, var2, false);
         this.g = var2;
      }

   }

   private void a(int var1, int var2, int var3) {
      if (this.s > var1) {
         this.s = var1;
         this.t = var2;
         this.e[var3] = true;
         if (this.g < var3) {
            com.aspose.cells.a.c.zc.a(this.e, this.g, var3, false);
            this.g = var3;
         }
      } else if (var2 > this.t) {
         this.e[var3] = false;
      } else {
         this.e[var3] = true;
         if (var2 < this.t) {
            this.t = var2;
            if (this.g < var3) {
               com.aspose.cells.a.c.zc.a(this.e, this.g, var3, false);
               this.g = var3;
            }
         }
      }

   }

   private void b(int var1, int var2, int var3) {
      if (var1 > this.s) {
         this.e[var3] = false;
      } else {
         this.e[var3] = true;
         if (var1 < this.s) {
            this.s = var1;
            this.t = var2;
            if (this.g < var3) {
               com.aspose.cells.a.c.zc.a(this.e, this.g, var3, false);
               this.g = var3;
            }
         } else if (var2 < this.t) {
            this.t = var2;
            if (this.g < var3) {
               com.aspose.cells.a.c.zc.a(this.e, this.g, var3, false);
               this.g = var3;
            }
         }
      }

   }

   private void C() {
      this.g = this.l;

      for(int var2 = this.l; var2 < this.m; ++var2) {
         zahn var1 = this.b[var2];
         var1.f();
         if (var1.g()) {
            this.f[var2] = true;
            int var3 = var1.j();
            if (var3 == this.t) {
               this.e[var2] = true;
            } else if (var3 < this.t) {
               this.t = var3;
               this.e[var2] = true;
               if (this.g < var2) {
                  com.aspose.cells.a.c.zc.a(this.e, this.g, var2, false);
                  this.g = var2;
               }
            } else if (this.g == var2) {
               ++this.g;
            }
         } else {
            this.f[var2] = false;
            this.e[var2] = false;
            if (this.g == var2) {
               ++this.g;
            }
         }
      }

   }

   public boolean a(int var1) {
      return this.b(var1 / this.k, var1 % this.k);
   }

   public void f() {
      super.f();
      this.s = -1;
      this.t = this.k;
   }

   public boolean g() {
      zahn var1;
      if (this.i > -1) {
         var1 = this.b[this.i];
         if (var1.m()) {
            if (this.f[this.i]) {
               this.i = -1;
               return this.b(this.s, var1.j());
            }

            ++this.s;
            if (this.s < this.j) {
               var1.f();
               if (var1.g()) {
                  this.i = -1;
                  return this.b(this.s, var1.j());
               }
            }
         } else if (var1.n()) {
            if (this.f[this.i]) {
               this.i = -1;
               return this.b(var1.i(), 0);
            }
         } else if (this.f[this.i]) {
            this.i = -1;
            return this.b(var1.i(), var1.j());
         }

         this.i = -1;
         return false;
      } else {
         this.h = null;
         int var2 = this.t + 1;
         int var3;
         boolean var4;
         if (var2 >= this.k) {
            var3 = this.s + 1;
            if (var3 >= this.j) {
               return false;
            }

            var4 = true;
            var2 = 0;
         } else {
            var3 = this.s;
            var4 = false;
         }

         this.s = this.j;
         this.t = this.k;
         this.g = 0;

         int var5;
         for(var5 = 0; var5 < this.l; ++var5) {
            var1 = this.b[var5];
            if (this.e[var5]) {
               if (var1.g()) {
                  this.a(var1, var5);
               } else {
                  this.f[var5] = false;
                  this.e[var5] = false;
                  if (this.g == var5) {
                     ++this.g;
                  }
               }
            } else if (this.f[var5]) {
               this.a(var1, var5);
            } else if (this.g == var5) {
               ++this.g;
            }
         }

         if (this.m > this.l) {
            for(var5 = this.l; var5 < this.m; ++var5) {
               var1 = this.b[var5];
               if (var4) {
                  var1.f();
                  if (var1.g()) {
                     this.f[var5] = true;
                     this.a(var3, var1.j(), var5);
                  } else {
                     this.f[var5] = false;
                     this.e[var5] = false;
                     if (this.g == var5) {
                        ++this.g;
                     }
                  }
               } else if (this.e[var5]) {
                  if (var1.g()) {
                     this.a(var3, var1.j(), var5);
                  } else {
                     this.f[var5] = false;
                     this.e[var5] = false;
                     if (this.g == var5) {
                        ++this.g;
                     }
                  }
               } else if (this.f[var5]) {
                  this.a(var3, var1.j(), var5);
               } else if (this.g == var5) {
                  ++this.g;
               }
            }
         }

         if ((var4 || this.s > var3) && this.m < this.b.length) {
            for(var5 = this.m; var5 < this.b.length; ++var5) {
               var1 = this.b[var5];
               if (this.e[var5]) {
                  if (var1.g()) {
                     this.b(var1.i(), var2, var5);
                  } else {
                     this.f[var5] = false;
                     this.e[var5] = false;
                     if (this.g == var5) {
                        ++this.g;
                     }
                  }
               } else if (this.f[var5]) {
                  this.b(var1.i(), var2, var5);
               } else if (this.g == var5) {
                  ++this.g;
               }
            }
         }

         if (this.s > var3 && this.m > this.l) {
            if (this.s > var3 + 1) {
               this.s = var3 + 1;
               if (this.g < this.b.length) {
                  com.aspose.cells.a.c.zc.a(this.e, this.g, this.b.length, false);
               }

               this.t = this.k;
            }

            this.C();
            return true;
         } else {
            return this.g < this.b.length;
         }
      }
   }

   public zahn b(int var1) {
      if (this.m < this.b.length) {
         return new zaxf(this, this.a, var1);
      } else {
         zahn[] var2 = new zahn[this.b.length];

         for(int var3 = 0; var3 < this.b.length; ++var3) {
            var2[var3] = this.b[var3].b(var1);
         }

         return new zawr(var2, this.c, this.a);
      }
   }

   public zahn c(int var1) {
      if (this.m > this.l) {
         return new zaxe(this, this.a, var1);
      } else {
         zahn[] var2 = new zahn[this.b.length];

         for(int var3 = 0; var3 < this.b.length; ++var3) {
            var2[var3] = this.b[var3].c(var1);
         }

         return new zawr(var2, this.c, this.a);
      }
   }

   public zahn c(zaay var1) {
      if (!this.n) {
         this.D();
      }

      zawq var2 = new zawq(this, (zaay)null);
      zbvm var3 = new zbvm(var2, this.d, this.o, this.q, this.p, this.r, this.j, this.k);
      return new zawy(var2, var3, var1);
   }

   public boolean m() {
      return false;
   }

   public boolean n() {
      return false;
   }

   public int c() {
      return this.j;
   }

   public int d() {
      return this.k;
   }

   public int e() {
      return this.j * this.k;
   }

   public int i() {
      return this.s;
   }

   public int j() {
      return this.t;
   }

   public int k() {
      return this.s * this.k + this.t;
   }

   public boolean q() {
      return this.n;
   }

   public int r() {
      if (!this.n) {
         this.D();
      }

      return this.o;
   }

   public int s() {
      if (!this.n) {
         this.D();
      }

      return this.p;
   }

   public int t() {
      if (!this.n) {
         this.D();
      }

      return this.q;
   }

   public int u() {
      if (!this.n) {
         this.D();
      }

      return this.r;
   }

   private void D() {
      this.n = true;
      zahn var1;
      int var2;
      if (this.m > this.l) {
         this.o = 0;
         this.p = this.j - 1;
         if (this.m < this.b.length) {
            this.q = 0;
            this.r = this.k - 1;
            return;
         }

         var1 = this.b[0];
         this.q = var1.t();
         this.r = var1.u();

         for(var2 = 1; var2 < this.b.length; ++var2) {
            var1 = this.b[var2];
            this.q = Math.min(this.q, var1.t());
            this.r = Math.max(this.r, var1.u());
         }
      } else {
         this.q = 0;
         this.r = this.k - 1;
         var1 = this.b[0];
         this.o = var1.r();
         this.p = var1.s();

         for(var2 = 1; var2 < this.b.length; ++var2) {
            var1 = this.b[var2];
            this.o = Math.min(this.o, var1.r());
            this.p = Math.max(this.p, var1.s());
         }
      }

   }
}
